import java.util.ArrayList;

public class Ids{

	private String id;
	private ArrayList<String> idArray;
		
	private ArrayList<String> addIds = new ArrayList<String>();
	
	public Ids(Tokens tokens){
		this.idArray = new ArrayList<String>();
		this.addIds = this.parse(tokens);
	}
	
	public ArrayList<String> parse(Tokens tokens) {
		// if token is not an ID
		if(tokens.getToken() != 32){
			System.err.println("An ID must be declared after keyword \"int\" or a comma");
			System.exit(0);
		}
		this.id = tokens.idName();
		this.idArray.add(tokens.idName());
		
		Id.parseID(tokens);
		

		// if token is a ',' recursively add to the list of IDs by calling itself
		// (which is done in the constructor).
		if(tokens.getToken() == 13){
			tokens.skipToken();
			Ids tmp = new Ids(tokens);
		}
		while(this.addIds.size() > 0){ // *note to self* make sure this condition passes
			this.idArray.add(this.addIds.remove(0));
		}
		return this.idArray;
	}

	public String getCurrentID() {
		return this.id;
	}

	public ArrayList<String> getIdList(){
		return idArray;
	}
}